<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<style>
			.right {
				position: absolute;
				right: 3px;
				font-size: 6px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a href="function.html" class=" mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">请假记录</h1>
			<a href="askleave.html" id="menu" class="mui-icon mui-icon-plusempty mui-pull-right" href="#topPopover"></a>
		</header>
		<div id="cdiv" class="mui-content">

		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/public.js"></script>
		<script type="text/javascript" charset="utf-8">
			var createBy = localStorage.getItem("employeeid");
			//预加载

			mui.plusReady(function() {
				mload();
			});
			//交互:数据展示
			function mload() {
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
					console.log('网络正常,正在发送请求...');
					mui.ajax({
						url: 'http://113.71.26.27:8080/tpl/function/findleave',
						async: true,
						type: 'post',
						timeout: 2000,
						data: {
							createBy: createBy
						},
						success: function(data) {
							var tt = '';
							var infoList = data; //leave便签的数组
							for(var i = 0; i < infoList.length; i++) {
								//typeArr.push(infoList[i].id)
								if(infoList[i].state == "未审核") {
									tt += "<div class='mui-card' onclick=mupdate(" + infoList[i].id + ")><div class='mui-card-header mui-card-media'><img src='images/logo.png'/><div class='mui-media-body'><span>请假单 </span><span class='right'>" + mmtime(infoList[i].updateDate) + "</span></p><p>开始时间:" + mmtime(infoList[i].startTime) + "</p><p>结束时间:" + mmtime(infoList[i].endTime) + "</p><p id='reason'>请假原因:" + infoList[i].reason + "</p><p>状态:" + infoList[i].state + "</p></div></div></div>";
								} else {
									tt += "<div class='mui-card'><div class='mui-card-header mui-card-media'><img src='images/logo.png'/><div class='mui-media-body'><span>请假单 </span><span class='right'>" + mmtime(infoList[i].updateDate) + "</span></p><p>开始时间:" + mmtime(infoList[i].startTime) + "</p><p>结束时间:" + mmtime(infoList[i].endTime) + "</p><p>请假原因:" + infoList[i].reason + "</p><p>状态:" + infoList[i].state + "</p></div></div></div>";
								}
							}
							document.getElementById('cdiv').innerHTML = tt;
						}
					});
				} else {
					mui.toast("当前网络不给力，请稍后再试...");
				}
			}
			//编辑数据
			function mupdate(id) {
				var blocked = false;
				try {
					var url = "askleave.html?id=" + id;
					var newWin = window.open(url);
					if(newWin == null) {
						blocked = true;
					}
				} catch(ex) {
					block = true;
				}
				if(blocked) {
					alert("弹出窗口被阻止");
				}
			}
			/**
			 * 重写返回事件
			 */
			mui.back = function() {

				window.location.href = "function.html";
			}
		</script>
	</body>

</html>